<template>
  <div class="ma-content-block lg:flex justify-between p-4">
    <!-- CRUD 组件 -->
    <ma-crud :options="options" :columns="columns" ref="crudRef">
    </ma-crud>
  </div>
</template>
<script setup>
import { ref, reactive } from 'vue'
import financialAccountsPaylog from '@/api/financial/financialAccountsPaylog'
import { Message } from '@arco-design/web-vue'
import tool from '@/utils/tool'
import * as common from '@/utils/common'

const crudRef = ref()
const indexid = ref(0)

const open =  (row) => {
  indexid.value = row.user_id
  crudRef.value.refresh()
}

const numberOperation = (newValue, id, numberName) => {
  financialAccountsPaylog.numberOperation({ id, numberName, numberValue: newValue }).then( res => {
    res.success && Message.success(res.message)
  }).catch( e => { console.log(e) } )
}

const switchStatus = (statusValue, id, statusName) => {
  financialAccountsPaylog.changeStatus({ id, statusName, statusValue }).then( res => {
    res.success && Message.success(res.message)
  }).catch( e => { console.log(e) } )
}


const options = reactive({
  id: 'flyos_financial_accounts_paylog',
  rowSelection: {
    showCheckedAll: true
  },
  pk: 'id',
  operationColumn: false,
  operationWidth: 160,
  formOption: {
    viewType: 'modal',
    width: 600
  },
  api: financialAccountsPaylog.getList,
  recycleApi: financialAccountsPaylog.getRecycleList,
  // add: {
  //   show: true,
  //   api: financialAccountsPaylog.save,
  //   auth: ['financial:accountsPaylog:save']
  // },
  // edit: {
  //   show: true,
  //   api: financialAccountsPaylog.update,
  //   auth: ['financial:accountsPaylog:update']
  // },
  // delete: {
  //   show: true,
  //   api: financialAccountsPaylog.deletes,
  //   auth: ['financial:accountsPaylog:delete'],
  //   realApi: financialAccountsPaylog.realDeletes,
  //   realAuth: ['financial:accountsPaylog:realDeletes']
  // },
  // recovery: {
  //   show: true,
  //   api: financialAccountsPaylog.recoverys,
  //   auth: ['financial:accountsPaylog:recovery']
  // },
  // import: {
  //   show: true,
  //   url: 'financial/accountsPaylog/import',
  //   templateUrl: 'financial/accountsPaylog/downloadTemplate',
  //   auth: ['financial:accountsPaylog:import']
  // },
  export: {
    show: true,
    url: 'financial/accountsPaylog/export',
    auth: ['financial:accountsPaylog:export']
  },
  beforeRequest: (params) => {
    params.dept_id = indexid.value
	},
})

const columns = reactive([
  // {
  //   title: "",
  //   dataIndex: "id",
  //   formType: "input",
  //   addDisplay: false,
  //   editDisplay: false,
  //   hide: true,
  //   commonRules: {
  //     required: true,
  //     message: "请输入"
  //   }
  // },
  // {
  //   title: "收款方",
  //   dataIndex: "dept_id",
  //   formType: "input",
  //   search: true
  // },
  {
    title: "金额",
    dataIndex: "price",
    formType: "input"
  },
  {
    title: "创建人",
    dataIndex: "created_by",
    formType: "select",
    addDisplay: false,
    editDisplay: false,
    dict:{
      url:'system/user/index',
      params:{
        page:1,
        pageSize:1000
      },
      props:{label: 'nickname', value: 'id'},
      translation:true

    }
  },
  {
    title: "创建时间",
    dataIndex: "created_at",
    formType: "date",
    search: false,
    addDisplay: false,
    editDisplay: false,
    showTime: false
  },
  {
    title: "更新时间",
    dataIndex: "updated_at",
    formType: "date",
    addDisplay: false,
    editDisplay: false,
    hide: true,
    showTime: true
  },
  
])
defineExpose({ open });
</script>
<script> export default { name: 'financial:accountsPaylog' } </script>